<template>
	<view class="ys">
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="left">
					<image src="/static/img/alarm.png" mode="widthFix"></image>
				</view>
				<view class="right">
					<view class="title">
						报警人：{{item.alertUserName}}
						<text>{{statusType[item.status]}}</text>
					</view>
					<view class="phone">
						详细地址：{{item.address}}
					</view>
					<view class="phone">
						处理人：{{item.handleUserName || '暂无'}}
					</view>
					<view class="time">
						报警时间：{{item.createTime}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		personalAlertlist
	} from "@/api/api.js"
	export default {
		data() {
			return {
				page: 1,
				last_page: 1,
				list: [],
				statusType: {
					0: '待处理',
					1: '排查中',
					2: '已处理'
				}

			}
		},
		onLoad() {
			this.personalAlertlist()
		},
		onReachBottom() {
			if (this.page < this.last_page) {
				this.page++
				this.personalAlertlist()
			}
		},
		methods: {
			personalAlertlist() {
				personalAlertlist({
					pageNum: this.page,
					pageSize: 15
				}).then(res => {
					if (res.code == 200) {
						this.list = this.list.concat(res.data.records)
						this.page = res.data.pages
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.ys {
		background: #f2f2f2;
		height: 100%;
		box-sizing: border-box;
		padding: 10px 0;
		min-height: 100vh;
		/* #ifdef H5 */
		min-height: calc(100vh - 44px);
		/* #endif */
	}

	.list {
		padding: 0 10px;

		.item {
			background: #fff;
			margin-bottom: 10px;
			border-radius: 6px;
			padding: 10px;
			font-size: 14px;
			display: flex;
			align-items: center;

			image {
				width: 40px;
			}

			.left {
				padding: 0 20px 0 10px;
			}

			.right {
				flex: 1;
			}

			.title {
				font-weight: bold;
				font-size: 15px;
				display: flex;
				align-items: center;
				justify-content: space-between;

				text {
					font-size: 12px;
					color: #f00;
				}
			}

			.phone {
				color: #777;
				margin-top: 5px;
				font-size: 12px;
			}

			.time {
				color: #777;
				margin-top: 5px;
				font-size: 12px;
			}
		}
	}
</style>